package com.wc.alorithm_blue_bridge._数据结构.KMP.Q3754;

import java.util.Scanner;
/**
 * @Author congege
 * @Description
 *
 *
 * @Date Created in 2023/12/2-16:08
 */
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        int lenS = s.length();
        int ans = 0;
        for(int i = 0; i < lenS; i++){
            String compare = s.substring(i,lenS);
            int[] next = new int[lenS + 1 - i];
            int len = next.length;
            int k;
            next[0] = -1;
            next[1] = 0;
            int j = 2;
            while(j < len){
                k = next[j - 1];
                if(k != -1 && compare.charAt(j - 1) != compare.charAt(k)){
                    k = next[k];
                }
                next[j] = k + 1;
                ans = Math.max(ans,next[j]);
                ++j;
            }
        }
        System.out.println(ans);
        scan.close();
    }
}
